Serialise list-typed query parameters as repeated key=value pairs - #541
Merged
Conversation
List- and array-typed [<Query>] parameters were stringified with .ToString(), producing F# list syntax in the URL (e.g. "status-types=%5Bx%3B%20y%5D" for Gitea's NotifyGetList); int[] didn't even compile under net9.0 nullness checking. Each element now contributes its own key=value pair (the "multi" collection format, which is what every array parameter in the Gitea spec declares, and RestEase's convention), individually escaped. The query string is now computed at runtime as a list of per-parameter string-list components, concatenated and appended to the URL (with separator) only when nonempty, so an empty list contributes nothing and an all-empty query leaves the URL bare. Required scalar parameters produce byte-identical URLs to before. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 9, 2026
The `queryString` local we emit to hold the serialised query string is in scope for the URI, body and header expressions, all of which may refer to the method's own parameters. A parameter named `queryString` was therefore captured: a `[<Path>] queryString` alongside any other query parameter silently used the serialised query string as the path value, and the generated code still compiled, so nothing caught it. Allocate the binding's name from the set of parameter names instead, so it cannot collide. The name is unchanged when no parameter shares it, so no existing generated output moves. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract the queryString name-allocation loop into a pure `freshName` helper and pin its invariants with FsCheck: the allocated name is never one already taken, a free name is returned unchanged (so an endpoint that doesn't collide never moves its generated output), and we only ever suffix the requested name. Extraction leaves all generated output byte -identical. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…WoofWare.Myriad into fix-list-query-stringification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
List- and array-typed
[<Query>]parameters were stringified with.ToString(), producing F# list syntax in the URL — e.g. Gitea'sNotifyGetListsentstatus-types=%5Bx%3B%20y%5D. Anint[]query parameter didn't even compile under net9.0 nullness checking (ToString()on the array isstring | null).Each element now contributes its own
key=valuepair, individually escaped — the "multi" collection format, which is what every array query parameter in the Gitea spec declares, and RestEase's convention for enumerable query parameters. (csv/ssv/tsv/pipes collection formats remain unsupported; nothing consumes them here today.)Mechanically, the query string becomes a runtime computation: each parameter contributes a
string listcomponent ([ "limit=10" ]for scalars,List.map/Seq.mapfor lists and arrays), and the concatenation is appended to the URL — with separator — only when nonempty. So an empty list contributes nothing, and a query consisting solely of empty lists leaves the URL bare. Required scalar parameters produce byte-identical URLs to before.Tests were written first and observed failing:
TestHttpClient/TestListQueryParam.fscovers repeated pairs, empty-list omission, bare-URL behaviour, per-element escaping, and the array case, driven through a generated client against a mock handler.Note: this deliberately branches off
mainrather than stacking on #540, but both rewrite the same query-string codegen block inHttpClientGenerator.fs, so whichever merges second will conflict there. The reconciliation is to unify the component type: #540 buildsstring optioncomponents (Option.map/List.choose) for optional scalars; this PR buildsstring listcomponents. The union isstring listcomponents throughout, with optional scalars mapped viaOption.toList.🤖 Generated with Claude Code